﻿namespace dotnet_notes.Profiles
{
    /// <summary>
    /// AutoMapper 业务相关映射配置类
    /// </summary>
    public class BusinessProfile : Profile
    {
        public BusinessProfile()
        {
            #region 品牌

            // 添加专用
            CreateMap<Sys_BrandAddReq, Sys_Brand_Examine>()
                .ForMember(dest => dest.SubmitTime, opt => opt.MapFrom(src => DateTime.Now))
                .ForMember(dest => dest.ExamineType, opt => opt.MapFrom(src => ExamineTypeEnum.Add))
                .ForMember(dest => dest.ExamineStatus, opt => opt.MapFrom(src => ExamineStatusEnum.PendingApproval));

            // 修改或审核修改专用
            CreateMap<Sys_BrandModifyReq, Sys_Brand_Examine>()
                .ForMember(dest => dest.SubmitTime, opt => opt.MapFrom(src => DateTime.Now))
                .ForMember(dest => dest.ExamineStatus, opt => opt.MapFrom(src => ExamineStatusEnum.PendingApproval));

            // 删除或恢复专用
            CreateMap<Sys_Brand, Sys_Brand_Examine>()
                .ForMember(dest => dest.SubmitTime, opt => opt.MapFrom(src => DateTime.Now))
                .ForMember(dest => dest.ExamineStatus, opt => opt.MapFrom(src => ExamineStatusEnum.PendingApproval))
                .ForMember(dest => dest.BusinessID, opt => opt.MapFrom(src => src.ID));

            // 审核通过通用
            CreateMap<Sys_Brand_Examine, Sys_Brand>()
                .ForMember(dest => dest.RecordStatus, opt => opt.MapFrom(src => RecordStatusEnum.Active))
                .ForMember(dest => dest.ID, opt => opt.Ignore());

            // 审核驳回专用
            CreateMap<Sys_Brand_Examine, Sys_Brand_Examine>()
                .ForMember(dest => dest.SubmitTime, opt => opt.MapFrom(src => DateTime.Now))
                .ForMember(dest => dest.ExamineStatus, opt => opt.MapFrom(src => ExamineStatusEnum.PendingModify))
                .ForMember(dest => dest.ExamineRemark, opt => opt.MapFrom(src => ""));

            #endregion
        }
    }
}
